<#assign ctx=request.contextPath />
<#import '${ctx}/sys/include/head.html' as d/>
<#import '${ctx}/sys/include/table/select.html' as select />
<!DOCTYPE html>
<html>
<head>
<@d.head title="table" />
</head>
<body>
<div class="layui-container" style="margin-top:12px;">
	<div class="layui-row">
		<div class="layui-form">
			<div class="layui-form-item">
				<div class="layui-inline">
				<label class="layui-form-label">字段选择</label>
				<div class="layui-input-inline" style="width:520px;">
					<div id="search_area_query">
						<input type="text" placeholder="点击选择字段" autocomplete="off" name="query_field_name"
						class="layui-input" readonly="readonly">
						<input name="query_field_id" type="hidden" />
					</div>
				</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">操作选择</label>
					<div class="layui-input-inline">
						<select lay-filter="op_select">
								<option value="=">=</option>
								<option value=">">&gt;</option>
								<option value="<">&lt;</option>
								<option value="->">自定义</option>
						</select>
					</div>
					<input type="hidden" name="query_operator" value="=" />
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-form-label">过滤设置</div>
				<div class="layui-input-block">
					<div class="layui-inline">
						<div class="layui-input-inline" style="width:520px;">
							<input type="text" name="query_value" placeholder="设置条件" autocomplete="off"
									class="layui-input">
						</div>
					</div>
				</div>
			</div>
			<div class="layui-form-item" >
				<div class="layui-input-block">
			        <a id="check_btn" class="layui-btn layui-btn-sm">
						确定选择
			        </a>
			    </div>
			</div>
		</div>
		<script type="text/javascript">
			layui.use(['form','element','appJs'],function(){
				var form = layui.form
				,element = layui.element
				,app = layui.appJs
				,$ = layui.$;


				form.on('select(op_select)',function(data){
					var val = data.value;
					$('input[name="query_operator"]').val(val);
				})

				form.render();

				$("input[name='query_field_name']").unbind('click');
        		$("input[name='query_field_name']").bind('click',function(){
        			var $holder = $(this);
    				var index = parent.layer.open({
   					 type:2,
   					 title:'请选择',
   					 maxmin :true,
   					 content:['${ctx}/biz/c/p/field-select-table'],
   					 area:['70%','70%'],
   					 success:function(layero,index){
   						 console.log('->'+index)
   						 var i = index;
   						 var iframeWin = parent[layero.find('iframe')[0]['name']];
   						 $(iframeWin.document).find("#check_btn").bind('click',function(){
   							var checkStatus = iframeWin.layui.table.checkStatus('search_table');
   							var index = layer.getFrameIndex(iframeWin.name); //获取窗口索引
   							if(checkStatus.data.length == 1) {
   								var data = checkStatus.data[0];
   								var show = [];
   								for(var v in data) {
   									show.push(data[v])
   								}
   								$holder.val(data['alias']);
   								$holder.next().val(data['id']);
   							}
   							parent.layer.close(i);
   						});
   					 }
   				});
        		});
			})
		</script>
	</div>
</div>
</body>
</html>